<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link href="css/style.css" rel="stylesheet" type="text/css"/>
    <link href="/layui/css/layui.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="/layui/layui.js"></script>
    <script type="text/javascript" src="js/jquery.js"></script>

    <script type="text/javascript">

        layui.use('layer', function(){
            var layer = layui.layer;
        });

        function del(msg) {
            layer.confirm('确认要删除吗？',function(){
                $.post("delAnnouncement?id=" + msg,function (data) {
                    if (data == 1) {
                        layer.msg("成功删除!");
                        var id = setTimeout(function(){
                            location.reload();
                            clearTimeout(id);
                        },1000);
                    } else if (data == 0) {
                        layer.msg("删除失败");
                    }
                })
            });
        }
    </script>


</head>


<body>

<div class="place">
    <span>位置：</span>
    <ul class="placeul">
        <li><a href="#">首页</a></li>
        <li><a href="#">系统设置</a></li>
        <li><a href="#">公告处理</a></li>
    </ul>
</div>

<div class="rightinfo">

    <div class="tools">

        <ul class="toolbar">
            <li onclick="javascript:window.location.href='/editAnnouncement'"><span><img src="images/t01.png"/></span>添加</li>
        </ul>

    </div>


    <table class="tablelist">
        <thead>
        <tr>
            <th>类型<i class="sort"><img src="images/px.gif"/></i></th>
            <th>标题</th>
            <th>内容</th>
            <th>发布者</th>
            <th>发布时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${announcementPageInfo.list}" var="temp">
            <tr>
                <td>${temp.typename}</td>
                <td>${temp.title}</td>
                <td>${temp.content}</td>
                <td>${temp.username}</td>
                <td>${temp.time}</td>
                <td><a href="/updateAnnouncement?id=${temp.id}" class="tablelink">修改</a> <a href="#" class="tablelink" onclick="del(${temp.id})">删除</a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <div class="pagin">
        <div class="message">共<i class="blue">${announcementPageInfo.total}</i>条记录，当前显示第&nbsp;<i class="blue">${announcementPageInfo.pageNum}&nbsp;</i>/&nbsp;<i class="blue">${announcementPageInfo.pages}&nbsp;</i>页</div>
        <ul class="paginList">
            <li class="paginItem"><a href="/getAnnouncement?pageNum=1">首页</a></li>
            <c:choose>
                <c:when test="${announcementPageInfo.pageNum > 1}">
                    <li class="paginItem"><a href="/getAnnouncement?pageNum=${announcementPageInfo.pageNum - 1}">上一页</a></li>
                </c:when>
                <c:otherwise>
                    <li class="paginItem"><a href="javascript:;">上一页</a></li>
                </c:otherwise>
            </c:choose>
            <c:choose>
                <c:when test="${announcementPageInfo.pageNum < announcementPageInfo.pages}">
                    <li class="paginItem"><a href="/getAnnouncement?pageNum=${announcementPageInfo.pageNum + 1}">下一页</a></li>
                </c:when>
                <c:otherwise>
                    <li class="paginItem"><a href="javascript:;">下一页</a></li>
                </c:otherwise>
            </c:choose>
            <li class="paginItem"><a href="/getAnnouncement?pageNum=${announcementPageInfo.pages}">尾页</a></li>
        </ul>
    </div>
</div>
<script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
